package com.scuec.groupfive.Controller;

import com.github.pagehelper.PageInfo;
import com.scuec.groupfive.entity.QuestionInfo;
import com.scuec.groupfive.service.QuestionService;
import com.scuec.groupfive.service.QuestionService_two;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/question")
@CrossOrigin
public class QuestionController_two {

    @Autowired
    private QuestionService_two questionService;

    /**
     * 获取所有题目列表（不分页）
     * 访问路径：http://localhost:8080/question/list
     */
    @GetMapping("/list")
    public List<QuestionInfo> getQuestionList() {
        return questionService.getQuestionList();
    }

    /**
     * 分页获取题目列表
     * 访问路径：http://localhost:8080/question/pages?pageNum=1&pageSize=10
     * @param pageNum 当前页码
     * @param pageSize 每页显示数量
     */
    @GetMapping("/pages")
    public PageInfo<QuestionInfo> getQuestionPages(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize) {
        return questionService.getQuestionPages(pageNum, pageSize);
    }
}